<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class QimageController extends Controller
{
    public $layout="application.views.layouts.admin";

    //variable to upload images
    public $img;

  /**public function filters()
    {
        return array(
            'accessControl',
        );
    }

    public function accessRules() {
        return array(
        	
        	array('allow',
        	'actions'=>array('List','Del','Add','Update'),
        	'roles'=>array('admin')        	
        	),
        	array('deny',
        	'actions'=>array('List','Del','Add','Update'),
        	'roles'=>array('guest','user')
        	)
			
		);
    }
    */
    //function to view all image using nivo-slider
    public function actionList()
    {
        $img=images::model()->findAll();
        $this->render('application.views.qimage.list',array("img"=>$img));
    }

    //function add images to database
    public function actionAdd()
    {
        $images=new images();
        
            //$images->attributes=$_POST['up'];
            $img= CUploadedFile::getInstance($images, 'name_image');
            
            if ($img!=null) {
            	$img->saveAs('images/slider/'.$img);
            }
            $images->name_image=$img;
            if ($images->save())
            {
               $this->redirect('list');
            }
        
        //$this->render('application.views.qimage._list',array("image"=>$image));
    }
}
?>
